package org.example.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.pojo.Category;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 添加分类
     * @param category
     */
    @Insert("insert into supermarket.category(category_name, description, create_time, update_time) " +
            "values(#{categoryName}, #{description}, #{createTime}, #{updateTime})")
    void add(Category category);

    /**
     * 修改分类
     * @param category
     */
    void update(Category category);

    /**
     * 删除分类
     * @param id
     */
    @Delete("delete from category where id = #{id}")
    void delete(Integer id);

    /**
     * 查询所有分类
     * @return
     */
    @Select("select * from category")
    List<Category> getCategorylist();
}
